package com.example.dao.impl;


import com.example.dao.ISysRoleDao;
import com.example.entity.SysRole;
import com.example.utils.DBTools;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

public class SysRoleDaoImpl extends BaseDaoImpl<SysRole> implements ISysRoleDao {
	
	private Connection conn = DBTools.getConnection();

	@Override
	public List<SysRole> getAll() {
		List<SysRole> list = null;
		String sql = "select * from sys_role";
		Object[] params = new Object[] {};
		try {
			list = super.getForList(conn, sql, params);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return list;
	}

	@Override
	public SysRole get(int id) {
		SysRole role = null;
		String sql = "select * from sys_role where id = ?";
		Object[] params = new Object[] {id};
		try {
			role = super.get(conn, sql, params);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return role;
	}

}
